package com.kcht.itsed.mws.aleframework.biz;

import com.kcht.itsed.mws.aleframework.intf.ISubscriptionSender;
import com.kcht.itsed.mws.commmodel.SubscribedReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.jms.*;

/**
 * 本地JMS Topic的订阅报告发送器
 * @author 张文硕
 *
 */
@Component
public class LocalSubscriptionSender implements ISubscriptionSender{

	@Autowired
	@Qualifier("topicJmsTemplate")
	private JmsTemplate topicJmsTemplate;
	@Autowired
	@Qualifier("subscribedReportTopic")
	private Topic subscribedReportTopic;	//主题是 订阅者的报告

	@Override
	public void send(SubscribedReport report) {
		topicJmsTemplate.send(subscribedReportTopic, session -> session.createObjectMessage(report));
	}
}
